﻿#include "mythread.h"
#include <QElapsedTimer>
#include <QDebug>
#include <QThread>

MyThread::MyThread(QObject *parent) : QObject(parent)
{

}

void MyThread::begin(int num){
    qDebug() <<" 线程1："<< num<<" || "<<QThread::currentThread();
    QElapsedTimer time;
    time.start();
    for (int i=0; i<num; i++) {
        QThread::msleep(1000); // 处理任务
        emit working(i);
    }
    qDebug() <<"线程1，共耗时： "<<time.elapsed() <<" ms。";
    emit finish(QString::number(time.elapsed()));

}
